package com.itheima.reggie.controller;

import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.Orders;
import com.itheima.reggie.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单控制器
 */
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {


    @Autowired
    private OrderService orderService;

    // 方法三要素：方法名，参数及返回值
    @PostMapping("/submit")
    public R<String> submit(@RequestBody Orders orders){
        log.info("[下订单]，orders:{}",orders);
        // 通过订单业务类完成下订单
        orderService.submit(orders);
        return R.success("下单成功");
    }


}
